<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./moduleControl.xhtml">

            <ui:define name="tabContent">
                <h:form prependId="false">
                    <h:panelGrid columns="3">
                        <p:selectOneMenu id="fileList" value="#{configFileBean.selectedFilePath}" style="width: 200px">
                            <f:selectItems value="#{configFileBean.configFileMap}"/>
                        </p:selectOneMenu>
                        <p:commandButton rendered="#{sessionBean.hasRight('config-on-file', 'view')}"
                                         update="fileContent" value="Xem nội dung" action="#{configFileBean.viewFile()}"/>
                        <p:commandButton rendered="#{sessionBean.hasRight('config-on-file', 'delete')}"
                                         value="Xóa file" onclick="fileDeteleConfim.show()"/>

                        <p:confirmDialog message="Bạn muốn xóa file đã chọn?"  
                                         header="Xác nhận" severity="alert" widgetVar="fileDeteleConfim">  

                            <p:commandButton update="fileList fileContent"  value="Có" oncomplete="fileDeteleConfim.hide()"  
                                             action="#{configFileBean.deleteFile()}"/>

                            <p:commandButton value="Không" onclick="fileDeteleConfim.hide()" type="button" />   

                        </p:confirmDialog> 
                    </h:panelGrid>
                    <br/>
                    <p:inputTextarea id="fileContent" cols="90" rows="20" value="#{configFileBean.currentContent}" style="font-family: Courier New"/>
                    <br/>
                    <h:panelGrid columns="2">
                        <p:commandButton rendered="#{sessionBean.hasRight('config-on-file', 'update')}"
                                         update="fileContent" value="Lưu" action="#{configFileBean.saveFile()}"/>
                        <p:commandButton update="fileContent" value="Hủy bỏ" action="#{configFileBean.cancel()}"/>
                    </h:panelGrid>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
